<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1">
  <title id="ph137116">vacuumdb</title>
  <body>
    <p id="client_util_desc">Garbage-collects and analyzes a database.</p>
    <section id="section2">
      <title>Synopsis</title>
      <codeblock id="client_util_synopsis">vacuumdb [&lt;connection-option>...] [--full | -f] [--freeze | -F] [--verbose | -v]
    [--analyze | -z] [--analyze-only | -Z] [--table | -t &lt;table> [( &lt;column> [,...] )] ] [&lt;dbname>]

vacuumdb [&lt;connection-option>...] [--all | -a] [--full | -f] [-F] 
    [--verbose | -v] [--analyze | -z]
    [--analyze-only | -Z]

vacuumdb -? | --help

vacuumdb -V | --version</codeblock>
    </section>
    <section id="section3">
      <title>Description</title>
      <p><codeph>vacuumdb</codeph> is a utility for cleaning a Greenplum Database database.
        <codeph>vacuumdb</codeph> will
        also generate internal statistics used by the Greenplum Database query optimizer.</p>
      <p><codeph>vacuumdb</codeph> is a wrapper around the SQL command <codeph>VACUUM</codeph>.
        There is no effective difference between vacuuming databases via this utility and via other
        methods for accessing the server. </p>
    </section>
    <section id="section4">
      <title>Options</title>
      <parml>
        <plentry>
          <pt>-a | --all</pt>
          <pd>Vacuums all databases.</pd>
        </plentry>
        <plentry>
          <pt>[-d] <varname>dbname</varname> | [--dbname=]<varname>dbname</varname></pt>
          <pd>The name of the database to vacuum. If this is not specified and
            <codeph>-a</codeph> (or <codeph>--all</codeph>)
            is not used, the database name is read from the environment variable
              <codeph>PGDATABASE</codeph>. If that is not set, the user name specified for the
            connection is used.</pd>
        </plentry>
        <plentry>
          <pt>-e | --echo</pt>
          <pd>Echo the commands that <codeph>reindexdb</codeph> generates and sends to the
            server.</pd>
        </plentry>
        <plentry>
          <pt>-f | --full</pt>
          <pd>Selects a full vacuum, which may reclaim more space, but takes much longer and
            exclusively locks the table. <note type="warning">A <codeph>VACUUM FULL</codeph> is not
              recommended in Greenplum Database.</note></pd>
        </plentry>
        <plentry>
          <pt>-F | --freeze</pt>
          <pd>Freeze row transaction information.</pd>
        </plentry>
        <plentry>
          <pt>-q | --quiet</pt>
          <pd>Do not display a response.</pd>
        </plentry>
        <plentry>
          <pt>-t <varname>table</varname> [(<varname>column</varname>)] | --table=
              <varname>table</varname> [(<varname>column</varname>)]</pt>
          <pd>Clean or analyze this table only. Column names may be specified only in conjunction
            with the <codeph>--analyze</codeph> or <codeph>--analyze-all</codeph> options.
            Multiple tables can be vacuumed by writing multiple <codeph>-t</codeph> switches.
            If you specify columns, you probably have to escape the parentheses from the shell.</pd>
        </plentry>
        <plentry>
          <pt>-v | --verbose</pt>
          <pd>Print detailed information during processing.</pd>
        </plentry>
        <plentry>
          <pt>-z | --analyze</pt>
          <pd>Collect statistics for use by the query planner.</pd>
        </plentry>
        <plentry>
          <pt>-Z | --analyze-only</pt>
          <pd>Only calculate statistics for use by the query planner (no vacuum).</pd>
        </plentry>
        <plentry>
          <pt>-V | --version</pt>
          <pd>Print the <codeph>vacuumdb</codeph> version and exit.</pd>
        </plentry>
        <plentry>
          <pt>-? | --help</pt>
          <pd>Show help about <codeph>vacuumdb</codeph> command line arguments, and exit.</pd>
        </plentry>
      </parml>
      <sectiondiv id="section5">
        <b>Connection Options</b>
        <parml>
          <plentry>
            <pt>-h <varname>host</varname> | --host=<varname>host</varname></pt>
            <pd>Specifies the host name of the machine on which the Greenplum master database server is running. If not specified,
              reads from the environment variable <codeph>PGHOST</codeph> or defaults to
              localhost.</pd>
          </plentry>
          <plentry>
            <pt>-p <varname>port</varname> | --port=<varname>port</varname></pt>
            <pd>Specifies the TCP port on which the Greenplum master
              database server is listening for connections. If not specified, reads from the
              environment variable <codeph>PGPORT</codeph> or defaults to 5432.</pd>
          </plentry>
          <plentry>
            <pt>-U <varname>username</varname> | --username=<varname>username</varname></pt>
            <pd>The database role name to connect as. If not specified, reads from the environment
              variable <codeph>PGUSER</codeph> or defaults to the current system user name.</pd>
          </plentry>
          <plentry>
            <pt>-w | --no-password</pt>
            <pd>Never issue a password prompt. If the server requires password authentication and a
              password is not available by other means such as a <codeph>.pgpass</codeph> file, the
              connection attempt will fail. This option can be useful in batch jobs and scripts
              where no user is present to enter a password.</pd>
          </plentry>
          <plentry>
            <pt>-W | --password</pt>
            <pd>Force a password prompt.</pd>
          </plentry>
          <plentry>
            <pt>--maintenance-db=<varname>dbname</varname></pt>
            <pd>Specifies the name of the database to connect to discover what other databases
              should be vacuumed. If not specified, the <codeph>postgres</codeph> database will be
              used, and if that does not exist, <codeph>template1</codeph> will be used.</pd>
          </plentry>
        </parml>
      </sectiondiv>
    </section>
    <section id="section6">
      <title>Notes</title>
      <p><codeph>vacuumdb</codeph> might need to connect several times to the master server, asking
        for a password each time. It is convenient to have a <codeph>~/.pgpass</codeph> file in such
        cases. </p>
    </section>
    <section id="section7">
      <title>Examples</title>
      <p>To clean the database <codeph>test</codeph>:</p>
      <codeblock>vacuumdb test</codeblock>
      <p>To clean and analyze a database named <codeph>bigdb</codeph>:</p>
      <codeblock>vacuumdb --analyze bigdb</codeblock>
      <p>To clean a single table <codeph>foo</codeph> in a database named <codeph>mydb</codeph>, and
        analyze a single column <codeph>bar</codeph> of the table. Note the quotes around the table
        and column names to escape the parentheses from the shell:</p>
      <codeblock>vacuumdb --analyze --verbose --table 'foo(bar)' mydb</codeblock>
    </section>
    <section id="section8">
      <title>See Also</title>
      <p>
        <ph><codeph>VACUUM</codeph> and <codeph>ANALYZE</codeph> in the <i>Greenplum Database
            Reference Guide</i></ph>
        <ph><xref href="../../ref_guide/sql_commands/VACUUM.xml#topic1"/>, <xref
            href="../../ref_guide/sql_commands/ANALYZE.xml#topic1"/></ph>
      </p>
    </section>
  </body>
</topic>
